package com.homedo.odin.solution.controller.pc;


import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.Meta;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.core.common.exception.BizException;
import com.homedo.core.common.util.NumberHelper;
import com.homedo.odin.solution.model.dto.AttachmentInfoResponseBean;
import com.homedo.odin.solution.service.bizservice.pc.PcAttachmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "附件", tags = {"Attachment"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/attachment")
public class AttachmentController extends BaseController<PcAttachmentService> {

    @GetMapping("/{id}")
    @ApiOperation(value = "PC_获取附件转图片详细信息", httpMethod = "GET")
    public ResultData collectSpecialColumn(@ApiParam(value = "id", required = true) @PathVariable("id") Integer id) {
        if (!NumberHelper.validate(id)) {
            throw new BizException(Meta.CODE_451.getCode(), "id参数错误");
        }

        AttachmentInfoResponseBean attachmentInfo = baseService.getAttachmentInfo(id);
        return ResultData.newInstance(Meta.CODE_200, attachmentInfo);
    }


}
